/*------ceshi----------*/
var userurl = "http://106.75.101.210:9092";
var mkurl = "http://106.75.101.210:8282";
/*---------bendi---------*/
//var userurl = "http://192.168.0.164:9092";

//点击切换
//mui('.mui-bar-tab').on('tap', '#personpage', function() {
//	mui.openWindow({
//		url: 'portal.html',
//		id: 'portal'
//	});
//});
mui('.mui-bar-tab').on('tap','#home',function(){
	var homePage = plus.webview.getLaunchWebview();
	plus.webview.show(homePage);
});
function topagej(topage) {
	if(topage == 'back') {
		mui.back();
	}
	if(topage == 'home') {
		var homePage = plus.webview.getLaunchWebview();
		plus.webview.show(homePage);
	}
	if(topage == 'person') {
		mui.openWindow({
			url: 'person1.html',
			id: 'person1'
		});
	}
	if(topage == 'listpub') {
		mui.openWindow({
			url: 'listpub.html',
			id: 'listpub'
		});
	}
	if(topage == 'myfollow') {
		mui.openWindow({
			url: 'myfollow.html',
			id: 'myfollow'
		});
	}
	if(topage == 'listpubno') {
		mui.openWindow({
			url: 'listpubno.html',
			id: 'listpubno'
		});
	}
}

function toLogin() {
	mui.openWindow({
		url: 'reg.html',
		id: 'reg'
	})
}

// 获取url中的参数
function getUrlParam(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) {
		return unescape(r[2]);
	} else {
		return null;
	}
}

function formatDate(date, fmt) {
	var o = {
		"M+": date.getMonth() + 1, //月份   
		"d+": date.getDate(), //日   
		"h+": date.getHours(), //小时   
		"m+": date.getMinutes(), //分   
		"s+": date.getSeconds(), //秒   
		"q+": Math.floor((date.getMonth() + 3) / 3), //季度   
		"S": date.getMilliseconds() //毫秒   
	};
	if(/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
	for(var k in o)
		if(new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
}

var message = null;
// 监听plusready事件  
document.addEventListener("plusready", function() {
	message = document.getElementById("message");
	// 监听点击消息事件
	plus.push.addEventListener("click", function(msg) {
		// 判断是从本地创建还是离线推送的消息
		switch(msg.payload) {
			case "LocalMSG":
				outSet("点击本地创建消息启动：");
				break;
			default:
				outSet("点击离线推送消息启动：");
				break;
		}
		// 提示点击的内容
		plus.nativeUI.alert(msg.content);
		// 处理其它数据
		logoutPushMsg(msg);
	}, false);
	// 监听在线消息事件
	plus.push.addEventListener("receive", function(msg) {
		if(msg.aps) { // Apple APNS message
			outSet("接收到在线APNS消息：");
		} else {
			outSet("接收到在线透传消息：");
		}
		logoutPushMsg(msg);
	}, false);
}, false);